#
# Iconv for Ruby for the Windows One-Click Installers that don't include it.
#
# iconv.so ->    ruby\lib\ruby\1.8\i386-mswin32\
# iconv.dll ->   windows\system32\
# charset.dll -> windows\system32\
#
# See README for details.
#
# Author: Dave Burt <dave@burt.id.au>
# Created: 28 Aug 2005
# Last modified: 15 Dec 2005
#

require 'win32ole'
require 'fileutils'

ruby_dir = WIN32OLE.new("WScript.Shell").
               RegRead("HKLM\\SOFTWARE\\Ruby\\RubyInstaller\\DefaultPath")

target_dir = File.join(ruby_dir, "lib/ruby/1.8/i386-mswin32")

win_dir = File.join(ENV['windir'], "System32")

puts "Setup has detected Ruby at #{ruby_dir}"
puts "and Windows/System32 at #{win_dir}"

print "Install Iconv there? [yN] "

if gets =~ /^y/i
    FileUtils.copy "iconv.so", target_dir, :verbose => true
    FileUtils.copy "iconv.dll", win_dir, :verbose => true
    FileUtils.copy "charset.dll", win_dir, :verbose => true
    require 'iconv'
    puts "Installation successful."
end
